package com.pets.web.controller.admin;


import com.pets.common.core.controller.BaseController;
import com.pets.common.core.domain.AjaxResult;
import com.pets.common.core.page.TableDataInfo;
import com.pets.web.entity.PetsComment;
import com.pets.web.entity.PetsDelivery;
import com.pets.web.service.IPetsCommentService;
import com.pets.web.service.IPetsDeliveryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 * 发货管理 前端控制器
 * </p>
 *
 * @author zhurenwang
 * @since 2024-05-26
 */
@RestController
@RequestMapping("/delivery")
public class PetsDeliveryController extends BaseController {

    @Autowired
    private IPetsDeliveryService petsDeliveryService;

    @GetMapping("/list")
    public TableDataInfo list(PetsDelivery petsDelivery){
        startPage();
        List<PetsDelivery> list = petsDeliveryService.list(petsDelivery);
        return getDataTable(list);
    }

    @PostMapping()
    public AjaxResult add(@RequestBody PetsDelivery petsDelivery){
        return success(petsDeliveryService.add(petsDelivery));
    }

    @DeleteMapping("/{id}")
    public AjaxResult delete(@PathVariable Integer id){
        return success(petsDeliveryService.deleteById(id));
    }

    @GetMapping("/{id}")
    public AjaxResult get(@PathVariable Integer id){
        return success(petsDeliveryService.getById(id));
    }

    @PutMapping()
    public AjaxResult edit(@RequestBody PetsDelivery petsDelivery){
        return success(petsDeliveryService.updateById(petsDelivery));
    }

}
